<?php
/**
 * 快递100 查询
 */
namespace request\express;

use request\Request;

class Kuaidi100QueryRequest extends Request {

    protected $method = 'post';
    protected $config = [
        'key' => '',
        'customer' => '',
    ];

    public function __construct()
    {
        $this->config = config('kuaidi100');
        $url = 'http://poll.kuaidi100.com/poll/query.do';
        $this->setUrl($url);
    }

    /**
     * 请求数据转化
     * @param array $params
     * @param int $dimension // 数组维度
     * @return array
     */
    protected function requestTransfer($params = [], $dimension = 1)
    {
        $data = [
            'param' => '{"com":"'.$params['com'].'","num":"'.$params['num'].'","from":"","to":""}',
            'customer' => $this->config['customer'],
        ];

        $data['sign'] = strtoupper(md5($data['param'].$this->config['key'].$data['customer']));
        return $data;
    }

    // 响应验证
    public function checkResponse($response)
    {
        parent::checkResponse($response); // TODO: Change the autogenerated stub
    }

    // 获取响应
    public function getResponse()
    {
        return parent::getResponse(); // TODO: Change the autogenerated stub
    }

    // 重构 响应
    public function setResponse($response)
    {
        parent::setResponse($response); // TODO: Change the autogenerated stub
    }
}